The present invention relates to the field of digital image processing. More specifically, the present invention relates to a method and apparatus for controlling video encoder output bit rate using progressive re-quantization.
Interframe video encoding systems predict a current frame from a previously reconstructed frame and perform quantization on the residual between the previous frame on a region-by-region basis. For example, in the Moving Pictures Experts Group 2 (MPEG-2) Video Compression Standard, published 1994, macroblocks of 16xc3x9716 pixels are predicted and the residual of the macroblocks are encoded. If a particular data rate is required for the transmission of the encoded bitstream within a bandlimited channel, data rate control is employed to encode each frame according to a specific bit allocation budget. A coding control unit is a component of the video encoder that is responsible for managing the tradeoff between the perceived video quality (spatial and temporal) of an encoded bitstream and the bandwidth required by the encoded bitstream. In practice, video is captured at a given frame rate F (frames per second), encoded, and transmitted over a channel of bandwidth B (bits per second). The coding control unit modulates video quality to ensure that the channel utilization stays within the available bandwidth B. Video quality is modulated spatially by choosing coarse or fine quantizers at encode time or temporally by selectively dropping encoded frames.
When the encoder misses the target frame size and uses too many bits to encode individual frames, output buffer overflow occurs. When output buffer overflow occurs, the encoder must modulate video quality temporally by dropping frames. Temporal modulation of video quality is typically undesirable because it results in jerkiness in the perceived video. To avoid frame skipping induced by buffer overflow, a rate control strategy must modulate spatial quality precisely and chooses quantizer levels that lead to buffer utilization on a per frame basis to meet the target frame size R=B/F (bits per frame).
A method for processing image data is disclosed. A region in a frame is quantized with an initial quantizer level. It is determined whether an amount of bits required for encoding the region after quantizing the region with the initial quantizer level is within a bit allocation budget. The region is re-quantized if the amount of bits is not within the bit allocation budget.